﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using KingCat_ValidateCheck;
using KingCat_Socket;

namespace KingCat_Client
{
    public partial class ServerInfo : Form
    {
        public ServerInfo()
        {
            InitializeComponent();
            this.label1.Visible = false;
            skinEngine1.SkinFile = @"../../SkinFiles/MP10/MP10.ssk";
        }


       /// <summary>
        /// 实现服务器连接，若连接不成功，则推出，否则则进入系统登入界面
       /// </summary>
       /// <param name="sender"></param>
       /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            label1.Visible = false;
            Boolean flag = ValidateCheck.getInstance().ValidateIpAndPort(textBox1.Text, textBox2.Text);
            if (flag == false)
            {
                label1.Visible = true;
                label1.ForeColor = Color.Red;
            }
            else
            {
                //与服务器建立连接，并初始化网络输入输出流
                if (ConnectServerSocket.getInstance().getTcpClient() == null)
                {
                    try
                    {
                        ConnectServerSocket.getInstance().SetConnectInfo(textBox1.Text, textBox2.Text);
                        this.Visible = false;
                        new Login().ShowDialog();
                    }
                    catch (Exception e4)
                    {
                        MessageBox.Show("无法找到目标主机，可能没联网或ip地址与端口号有错误!", "温馨提示");
                       
                    }
                }
            }
        }


        private void ServerInfo_Load(object sender, EventArgs e)
        {

        }


        private void button2_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}